package com.roadjava.tutor.handler.back.common;

import com.roadjava.tutor.bean.dto.UserDTO;
import com.roadjava.tutor.bean.entity.Member;
import com.roadjava.tutor.bean.res.ResultDTO;
import com.roadjava.tutor.service.MemberService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 学生/教师 共有功能控制器
 * @author zhaodaowen
 * @see <a href="http://www.roadjava.com">乐之者java</a>
 */
@Controller
@RequestMapping("/memberCommon")
public class MemberCommonHandler {
    @Resource
    private MemberService memberService;

    /**
     * 到欢迎页面
     */
    @GetMapping("/toWelcome")
    public String toWelcome(){
        return "back/common/welcome";
    }
    /**
     * 到个人信息页面
     */
    @GetMapping("/toUpdate")
    public String toUpdate(){
        return "back/common/update";
    }

    /**
     * 根据id查询一个会员
     */
    @GetMapping("/selectOneById") @ResponseBody
    public ResultDTO<Member> selectOneById(@RequestParam("id") Long id){
        return memberService.selectOneById(id);
    }
    /**
     * 根据id更新会员
     */
    @PostMapping("/trueUpdate") @ResponseBody
    public ResultDTO<String> trueUpdate(UserDTO userDTO){
        return memberService.trueUpdate(userDTO);
    }
}
